package sys.util;

import sys.database.Database;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class PlayerUtil {

    public static void showPlayer(String eventId, String playerID) {
        String sql = "select * from player where playerID = " + playerID + "and eventID = " + eventId;
        PreparedStatement preparedStatement = new Database().createConnection(sql);
        try {
            ResultSet res = preparedStatement.executeQuery();
            if (res.next()) {
                String playerName = res.getString("playerName");
                String eventID = res.getString("eventID");
                String eventName = res.getString("eventName");
                double score = res.getDouble("score");
                System.out.println("学/工号" + '\t' + "姓名" + '\t' + "项目编号" + '\t' + "项目名" + '\t' + "项目成绩");
                System.out.println(playerID + "\t" + playerName + "\t" + eventID + "\t" + eventName + "\t" + score);
            }
        } catch (SQLException e) {
            System.out.println("运动员检索失败！");
        }
    }
}
